package com.great.mapstruct.convert;

import com.great.mapstruct.entity.StudentInfo;
import com.great.mapstruct.util.ConvertUtils;
import com.great.mapstruct.vo.StudentVO;
import org.mapstruct.IterableMapping;
import org.mapstruct.MapMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.control.DeepClone;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;

//@Mapper(mappingControl = DeepClone.class)
@Mapper(componentModel = "spring", mappingControl = DeepClone.class)
public interface StudentConvert {

	@Mapping(target = "sex", expression = "java(com.great.mapstruct.util.ConvertUtils.sexConvert(info.getSex()))")
	@Mapping(target = "birthday", source = "birthday", dateFormat = "yyyy/MM/dd")
	@Mapping(target = "type", source = "type.name")
	StudentVO infoToVo(StudentInfo info);

//	@IterableMapping(numberFormat = "$#.00")
//	List<String> scores(List<Double> scores);

	/**
	 * List 转 List
	 */
	List<StudentVO> infoToVo(List<StudentInfo> infos);

	/**
	 * Stream 转 List
	 */
	List<StudentVO> streamToVo(Stream<StudentInfo> infoStream);

	/**
	 * List直接转Set
	 */
	Set<StudentVO> streamToVoSet(List<StudentInfo> infoStream);


}
